#include "scutcheoneventobject.h"
#include "screenscutcheon.h"
#include "core/dir.h"
#include "core/stringdefines.h"
#include "mainwindow.h"
#include "scutcheonevent.h"

using namespace EarthView::World::Core;
using namespace EarthView::World::Spatial::Math;

CScutcheonEventObject::CScutcheonEventObject()
{
	mpActiveWindow = dynamic_cast<MainWindow* >(QApplication::activeWindow());
	mpLastScutcheon = NULL;
}

CScutcheonEventObject::~CScutcheonEventObject()
{

}

bool CScutcheonEventObject::onSelectedEvent(CScreenScutcheonEvent* e)
{
	if(!mpActiveWindow) return false;
	EVString name = e->getSelectedScreenScutcheon()->getName();
	if (name == "czsc")
	{
		mpActiveWindow->showHelp();
	}
	else if (name == "ldcydt")
	{
		mpActiveWindow->showLeaderMap();
	}
	else if (name == "exit")
	{
		mpActiveWindow->showExitFrm();
	}
	else if (name == "fs")
	{
		mpActiveWindow->lookDown();
	}
	else if (name == "45du")
	{
		mpActiveWindow->fortyfiveDegree();
	}
	else if (name == "ps")
	{
		mpActiveWindow->horizontalLook();
	}
	else if (name == "north")
	{
		mpActiveWindow->north();
	}
	//else if (name == "placename")
	//{
	//	mpActiveWindow->showPlaceName();
	//}
	//else if (name == "vector")
	//{
	//	mpActiveWindow->showVector();
	//}
	else if (name == "location")
	{
		mpActiveWindow->showLocation();
	}
	//else if (name == "layermanager")
	//{
	//	mpActiveWindow->showLayerManager();
	//}

	else if (name == "distancemeasure")
	{
		mpActiveWindow->distanceMeasure();
	}

	else if (name == "areameasure")
	{
		mpActiveWindow->areaMeasure();
	}
	else if (name == "ztdt")
	{
		mpActiveWindow->showTheme();
	}
	else if (name == "ssxgk")
	{
		mpActiveWindow->cityCountyProfile();
	}
	else if (name == "currentimage")
	{
		mpActiveWindow->switchImage();
	}
	else if (name == "cityAttribute")
	{
		mpActiveWindow->switchCityAttribute();
	}
	return true;
}

//bool CScutcheonEventObject::onMousehover(CScutcheonEvent* e)
//{
//
//	CScreenScutcheon* scutcheon =  e->getSelectedScutcheon();
//	if (scutcheon)
//	{
//		CVector2 pos = scutcheon->getPanelElementPostion(scutcheon->getName());
//		scutcheon->setPanelElementPostion(scutcheon->getName(),CVector2(pos.x-10,pos.y-10));
//		scutcheon->setPanelElementWidth(scutcheon->getName(),100);
//		scutcheon->setPanelElementHeight(scutcheon->getName(),100);
//		if (mpLastScutcheon)
//		{
//			mpLastScutcheon->setPanelElementPostion(mpLastScutcheon->getName(),mPos);
//			mpLastScutcheon->setPanelElementWidth(mpLastScutcheon->getName(),80);
//			mpLastScutcheon->setPanelElementHeight(mpLastScutcheon->getName(),80);
//		}
//
//		mpLastScutcheon = scutcheon;
//		mPos = pos;
//		return true;
//	}
//	/*else
//	{
//		if (mpLastScutcheon)
//		{
//			mpLastScutcheon->setPanelElementPostion(mpLastScutcheon->getName(),mPos);
//			mpLastScutcheon->setPanelElementWidth(mpLastScutcheon->getName(),80);
//			mpLastScutcheon->setPanelElementHeight(mpLastScutcheon->getName(),80);
//			mpLastScutcheon = NULL;
//		}
//		return true;
//	}*/
//	return false;
//}

//ev_bool CScutcheonEventObject::onEvent(CEvent *e)
//{
//	if(!e) return false;
//	CScreenScutcheonEventObject::onEvent(e);
//	if (e->type() == CScutcheonEvent::SET_MouseOn)
//	{
//		onMousehover(dynamic_cast<CScutcheonEvent* >(e));
//		return true;
//	}
//	return false;
//}